package com.study.gupao.activity;

import com.study.gupao.promotion.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: PromotionStrategyFactory
 * @Description: 活动促销策略工厂
 * @author: Administrator
 * @Date: 2019-03-14 15:15
 */
public class PromotionStrategyFactory {


    private static Map<String, PromotionStrategy> PROMOTION_STRATEGY_MAP = new HashMap<String,
                PromotionStrategy>();
    static {
        PROMOTION_STRATEGY_MAP.put(PromotionKey.RECHARGE_MONEY_MAX,new CouponStrategy());
        PROMOTION_STRATEGY_MAP.put(PromotionKey.RECHARGE_MONEY_MEDIUM,new CashbackStrategy());
        PROMOTION_STRATEGY_MAP.put(PromotionKey.RECHARGE_MONEY_MIN,new GroupbuyStrategy());
    }
    private static final PromotionStrategy NON_PROMOTION = new EmptyStrategy();
    private PromotionStrategyFactory(){}
    public static PromotionStrategy getPromotionStrategy(String promotionKey){
        PromotionStrategy promotionStrategy = PROMOTION_STRATEGY_MAP.get(promotionKey);
        return promotionStrategy == null ? NON_PROMOTION : promotionStrategy;
    }
    private interface PromotionKey{
        String RECHARGE_MONEY_MAX = "RECHARGE_MONEY_MAX";
        String RECHARGE_MONEY_MEDIUM = "RECHARGE_MONEY_MEDIUM";
        String RECHARGE_MONEY_MIN = "RECHARGE_MONEY_MIN";
    }


}
